import Vuex from 'vuex'
import Vue from 'vue'

Vue.use(Vuex)

// 缓存的数据
const state = {
	// apiUrl: 'https://api.arczlz.com',// 线上
	apiUrl: 'http://192.168.31.30:7200',// 本地
	wxIdentifier: uni.getStorageSync('wxIdentifier'),
	userToken: uni.getStorageSync('userToken'),
	userInfo: uni.getStorageSync('userInfo'),
}

const mutations = {
	// 修改微信的openId 
	editWxIdentifier(state, wxIdentifier) {
		uni.setStorageSync('wxIdentifier', wxIdentifier)
		state.wxIdentifier = wxIdentifier
	},

	// 修改userToken
	editUserToken(state, userToken) {
		uni.setStorageSync('userToken', userToken)
		state.userToken = userToken
	},

	// 修改用户缓存信息
	editUserInfo(state, userInfo) {
		uni.setStorageSync('userInfo', userInfo)
		state.userInfo = userInfo
	},
}

const store = new Vuex.Store({
	state,
	mutations
})
export default store
